<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/main.css">
    <style>
        .a {
            color: red;
        }

        .b {
            font-size: 2rem;
        }

        .c {
            border: solid;
        }
    </style>
</head>

<body>

    <div id="box" class="">hello jack</div>
    <script>
        const box = document.getElementById('box');
        // box.classList.toggle('a');//添加
        // setInterval(() => {
        //     box.classList.toggle('a');//添加/删除
        //     box.classList.toggle('b');//添加/删除
        //     box.classList.toggle('c');//添加/删除
        // }, 3000);
        setInterval(() => {
            // toggle
            if (box.classList.contains('a')) {
                box.classList.remove('a');
            } else {
                box.classList.add('a');
            }
        }, 3000);
    </script>
</body>

</html>